<template>
  <div>
    <RowAttribute :span="24" :label-width="labelWidth" label="视图">
      <a-select placeholder="请选择视图" v-model="config.viewId">
        <a-select-option v-for="item in formDefinition.views" :key="item.id">
          {{item.viewName}}
        </a-select-option>
      </a-select>
    </RowAttribute>
    <RowAttribute :span="24" :label-width="labelWidth" label="权限">
      <a-select placeholder="请选择权限" v-model="config.actionId">
        <a-select-option v-for="item in formDefinition.actions" :key="item.id">
          {{item.actionName}}
        </a-select-option>
      </a-select>
    </RowAttribute>
  </div>
</template>
<script>
import { createProps } from '@/utils'
import { createFormDefinition } from '@comp/hhd/design/FormDesigner/types'
import RowAttribute from '@comp/hhd/layout/RowAttribute.vue'

export default {
  name: 'AddNewButtonConfig',
  components: {
    RowAttribute
  },
  props: {
    menu: createProps(Object, () => undefined),
    formDefinition: createProps(Object, createFormDefinition),
    config: createProps(Object, () => ({
      viewId: undefined,
      actionId: undefined
    }))
  },
  data() {
    return {
      labelWidth: '100px'
    }
  },
  methods: {
    check() {
      if (!this.config.viewId || !this.config.actionId) {
        this.$message.warn('请选择视图和权限')
        return false
      }
      return true
    }
  }
}
</script>